package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.GCityArea;
import com.ruoyi.manage.service.IGCityAreaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行政区划管理Controller
 * 
 * @author ruoyi
 * @date 2025-10-11
 */
@RestController
@RequestMapping("/manage/cityArea")
public class GCityAreaController extends BaseController
{
    @Autowired
    private IGCityAreaService gCityAreaService;

    /**
     * 查询行政区划管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:cityArea:list')")
    @GetMapping("/list")
    public TableDataInfo list(GCityArea gCityArea)
    {
        startPage();
        List<GCityArea> list = gCityAreaService.selectGCityAreaList(gCityArea);
        return getDataTable(list);
    }

    /**
     * 导出行政区划管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:cityArea:export')")
    @Log(title = "行政区划管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GCityArea gCityArea)
    {
        List<GCityArea> list = gCityAreaService.selectGCityAreaList(gCityArea);
        ExcelUtil<GCityArea> util = new ExcelUtil<GCityArea>(GCityArea.class);
        util.exportExcel(response, list, "行政区划管理数据");
    }

    /**
     * 获取行政区划管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:cityArea:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gCityAreaService.selectGCityAreaById(id));
    }

    /**
     * 新增行政区划管理
     */
    @PreAuthorize("@ss.hasPermi('manage:cityArea:add')")
    @Log(title = "行政区划管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GCityArea gCityArea)
    {
        return toAjax(gCityAreaService.insertGCityArea(gCityArea));
    }

    /**
     * 修改行政区划管理
     */
    @PreAuthorize("@ss.hasPermi('manage:cityArea:edit')")
    @Log(title = "行政区划管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GCityArea gCityArea)
    {
        return toAjax(gCityAreaService.updateGCityArea(gCityArea));
    }

    /**
     * 删除行政区划管理
     */
    @PreAuthorize("@ss.hasPermi('manage:cityArea:remove')")
    @Log(title = "行政区划管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gCityAreaService.deleteGCityAreaByIds(ids));
    }
}
